Package edu.uky.ai.tic.ai
Class GameTree
java.lang.Object
edu.uky.ai.tic.ai.GameTree
public class GameTree
extends java.lang.Object
A game tree is a representation of all the possible states that could occur
during the play of game and how one state is reached from another.
- Author:
- Stephen G. Ware
-
Field Summary
Fields Modifier and Type Field Description java.util.ArrayList<GameTree>childrenThis node's children nodes (i.e.MovemoveThe move to resulted in the current stateGameTreeparentThe parent node of this tree (i.e.StatestateThe current state of the gamedoublevalueThe utility value of this state (i.e. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description GameTreegetNextChild()Constructs and returns the next child node of this node.booleanhasNextChild()Returns true if this node has more children nodes which have not yet been expanded.intsize()Returns the number of nodes in this tree.
-
Field Details
-
move
The move to resulted in the current state -
state
The current state of the game -
parent
The parent node of this tree (i.e. the state before this state) -
children
This node's children nodes (i.e. all possible next states) -
value
public double valueThe utility value of this state (i.e. how desirable it is for the player)
-
-
Constructor Details
-
GameTree
Constructs a new game tree with some initial state as the root.- Parameters:
initial- the initial state of the game
-
GameTree
Constructs a new game tree with a current state that resulted from taking a given move.- Parameters:
move- the move that resulted in this statestate- the state of the game after making that moveparent- the parent node (i.e. the previous state)
-
-
Method Details
-
size
public int size()Returns the number of nodes in this tree.- Returns:
- the number of nodes
-
hasNextChild
public boolean hasNextChild()Returns true if this node has more children nodes which have not yet been expanded.- Returns:
- true if there are more children nodes to add, false otherwise
-
getNextChild
Constructs and returns the next child node of this node.- Returns:
- the next child node
-